{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "3UWmQX3KG7HA"
   },
   "source": [
    "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1DZnUfeerjm3RJf1AqqbjR0Isb_8g3mTZ?usp=sharing)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "wlshOcHsZ3ff"
   },
   "source": [
    "# Build Phidata Assistant with Perplexity-AI using Portkey\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "## What is phidata?\n",
    "\n",
    "Phidata is a framework for building AI Assistants with memory, knowledge and tools.\n",
    "\n",
    "\n",
    "## Use phidata to turn any LLM into an AI Assistant (aka Agent) that can:\n",
    "\n",
    "* Search the web using DuckDuckGo, Google etc.\n",
    "\n",
    "* Pull data from APIs like yfinance, polygon etc.\n",
    "\n",
    "* Analyze data using SQL, DuckDb, etc.\n",
    "\n",
    "* Conduct research and generate reports.\n",
    "\n",
    "* Answer questions from PDFs, APIs, etc.\n",
    "\n",
    "* Summarize articles, videos, etc.\n",
    "\n",
    "* Perform tasks like sending emails, querying databases, etc.\n",
    "\n",
    "\n",
    "\n",
    "# Phidata integration with perplexity\n",
    "\n",
    "Using phidata assistants with perplexity enables the assistant to use the Internet natively. Bypassing the use of search engines like DuckDuckGo and Google, while still offering the option to use specific tools.\n",
    "\n",
    "\n",
    "# Why phidata\n",
    "\n",
    "Problem: We need to turn general-purpose LLMs into specialized assistants tailored to our use-case.\n",
    "\n",
    "* Solution: Extend LLMs with memory, knowledge and tools:\n",
    "\n",
    "* Memory: Stores chat history in a database and enables LLMs to have long-term conversations.\n",
    "\n",
    "* Knowledge: Stores information in a vector database and provides LLMs with business context.\n",
    "\n",
    "* Tools: Enable LLMs to take actions like pulling data from an API, sending emails or querying a database.\n",
    "\n",
    "* Memory & knowledge make LLMs smarter while tools make them autonomous.\n",
    "\n",
    "\n",
    "\n",
    "---\n",
    "\n",
    "\n",
    "**Portkey** is an open source [**AI Gateway**](https://github.com/Portkey-AI/gateway) that helps you manage access to 250+ LLMs through a unified API while providing visibility into\n",
    "\n",
    "✅ cost  \n",
    "✅ performance  \n",
    "✅ accuracy metrics\n",
    "\n",
    "This notebook demonstrates how you can bring visibility and flexbility to Phidata using Portkey's AI Gateway while using Perplexity.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "vLyClXvwbUVs"
   },
   "source": [
    "# Installing Dependencies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "id": "ljIFNOOQA00x"
   },
   "outputs": [],
   "source": [
    "!pip install phidata portkey-ai duckduckgo-search yfinance"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "xVjqdzYXbe9L"
   },
   "source": [
    "# Importing Libraries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "DOOJHmDMA9Ke"
   },
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "from phi.assistant import Assistant\n",
    "from phi.llm.openai import OpenAIChat\n",
    "\n",
    "from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "PERPLEXITY_VIRTUAL_KEY = os.getenv(\"PERPLEXITY_VIRTUAL_KEY\")\n",
    "PORTKEY_API_KEY = os.getenv(\"PORTKEY_API_KEY\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "CDAwVvuZeA_p"
   },
   "source": [
    "# Creating A Basic Assistant Using Phidata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000,
     "referenced_widgets": [
      "54ca51f62b6440d89ccaccbdebeaf941",
      "69a9dfbdaa454445b3a75ba27905f5b7"
     ]
    },
    "id": "aQYgJvdGdeYV",
    "outputId": "98b552a9-1793-497c-8712-506ee4acbe80"
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "54ca51f62b6440d89ccaccbdebeaf941",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Output()"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
      ],
      "text/plain": []
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Initialize the OpenAIChat model\n",
    "llm = OpenAIChat(\n",
    "    api_key=\"dummy\",  # Using Virtual Key instead\n",
    "    model=\"llama-3-sonar-small-32k-online\",  # Use your choice of model from Perplexity Documentation\n",
    "    base_url=PORTKEY_GATEWAY_URL,\n",
    "    default_headers=createHeaders(\n",
    "        virtual_key=PERPLEXITY_VIRTUAL_KEY,  # Replace with your virtual key for Anthropic from Portkey\n",
    "        api_key=PORTKEY_API_KEY,  # Replace with your Portkey API key\n",
    "    ),\n",
    ")\n",
    "\n",
    "# Financial analyst built using Phydata and Perplexity API\n",
    "\n",
    "Stock_agent = Assistant(\n",
    "    llm=llm,\n",
    "    show_tool_calls=True,\n",
    "    markdown=True,\n",
    ")\n",
    "\n",
    "Stock_agent.print_response(\"What is the price of Nvidia stock? Write a report about Nvidia in detail.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "FhKAyG2dxLi_"
   },
   "source": [
    "# Observability with Portkey"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "moXLgWBIxPyz"
   },
   "source": [
    "By routing requests through Portkey you can track a number of metrics like - tokens used, latency, cost, etc.\n",
    "\n",
    "Here's a screenshot of the dashboard you get with Portkey!\n",
    "\n",
    "\n",
    "![portkey_view.JPG](https://portkey.ai/blog/content/images/2024/07/Screenshot-2024-07-01-at-12.38.28-PM.png)"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3",
   "name": "python3"
  },
  "language_info": {
   "name": "python"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "54ca51f62b6440d89ccaccbdebeaf941": {
     "model_module": "@jupyter-widgets/output",
     "model_module_version": "1.0.0",
     "model_name": "OutputModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/output",
      "_model_module_version": "1.0.0",
      "_model_name": "OutputModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/output",
      "_view_module_version": "1.0.0",
      "_view_name": "OutputView",
      "layout": "IPY_MODEL_69a9dfbdaa454445b3a75ba27905f5b7",
      "msg_id": "",
      "outputs": [
       {
        "data": {
         "text/html": "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #000080; text-decoration-color: #000080\">╭──────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span><span style=\"font-weight: bold\"> Message  </span><span style=\"color: #000080; text-decoration-color: #000080\">│</span><span style=\"font-weight: bold\"> What is the price of Nvidia stock? write a report about Nvidia in detail                             </span><span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">├──────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────┤</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span> Response <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"font-weight: bold\">NVIDIA Corporation (NVDA) Stock Price and Overview</span>                                                   <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span> (6.9s)   <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                             <span style=\"font-weight: bold\">Stock Price</span>                                              <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> As of the current market, the stock price of NVIDIA Corporation (NVDA) is $124.30, with a trading    <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> volume of 261,458,283 shares. This represents a positive change of 0.62% compared to the previous    <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> day's close.                                                                                         <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                           <span style=\"font-weight: bold\">Company Overview</span>                                           <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> NVIDIA Corporation is a leading visual computing company based in Santa Clara, California. Founded   <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> in 1993, the company operates globally, with significant presence in the United States, Taiwan,      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> China, and Hong Kong. NVIDIA's primary business segments include Graphics, Compute &amp; Networking, and <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> Automotive.                                                                                          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                          <span style=\"font-weight: bold\">Business Segments</span>                                           <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Graphics</span>: NVIDIA's Graphics division delivers GeForce GPUs for gaming and personal computers,     <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>GeForce NOW for game streaming, and solutions for gaming platforms. It also offers Quadro/NVIDIA  <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>GPUs for workstation graphics, GPU software for cloud-based visual computing, and automotive      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>platforms for infotainment systems.                                                               <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Compute &amp; Networking</span>: This sector includes Data Center computing platforms, end-to-end networking <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>platforms, the NVIDIA DRIVE automated-driving platform, Jetson robotics, and NVIDIA AI Enterprise <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>software.                                                                                         <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Automotive</span>: NVIDIA provides solutions for automotive industries, including infotainment systems   <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>and autonomous driving platforms.                                                                 <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                          <span style=\"font-weight: bold\">Financial Insights</span>                                          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Market Capitalization</span>: NVIDIA's market capitalization stands at $3.195 trillion.                  <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Profitability Metrics</span>:                                                                            <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">    • </span><span style=\"font-weight: bold\">Profit Margin</span>: 53.40%.                                                                         <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">    • </span><span style=\"font-weight: bold\">Return on Assets (ROA)</span>: 49.10%.                                                                <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">    • </span><span style=\"font-weight: bold\">Return on Equity (ROE)</span>: 115.66%.                                                               <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Revenue</span>: The company generated $79.77 billion in the trailing twelve months.                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Cash and Cash Equivalents</span>: Total cash stands at $31.44 billion, with levered free cash flow of    <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>$29.02 billion.                                                                                   <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                         <span style=\"font-weight: bold\">Recent Market Trends</span>                                         <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> The second quarter of 2024 witnessed a positive trend in the equity market, with the S&amp;P 500 showing <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> a 4% increase and a year-to-date gain of nearly 15%. Growth sectors, particularly Information        <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> Technology and Communication Services, led the market during this period. However, sectors like      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> Estate, Materials Industrials Financial, and faced challenges. Looking ahead, the focus remains on   <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> Tech and Communications groups, with a question mark on whether small-caps will accelerate their     <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> growth. Amidst declining interest rates, growth stocks are expected to drive the market, while       <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> investors eyeing value are advised to consider dividends with yields in the 3-4% range.              <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                            <span style=\"font-weight: bold\">Recent Events</span>                                             <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">10-for-1 Stock Split</span>: NVIDIA announced a ten-for-one forward stock split to make stock ownership  <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>more accessible to employees and investors. The split will be effective on June 10, 2024, and     <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>trading will commence on a split-adjusted basis.                                                  <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">Increased Cash Dividend</span>: The company increased its quarterly cash dividend by 150% from $0.04 per <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>share to $0.10 per share of common stock. The increased dividend is equivalent to $0.01 per share <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>on a post-split basis and will be paid on June 28, 2024, to all shareholders of record on June    <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>11, 2024.                                                                                         <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                          <span style=\"font-weight: bold\">Financial Results</span>                                           <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> NVIDIA announced its financial results for the first quarter of fiscal 2025, reporting revenue of    <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> $26.04 billion and a gross margin of 78.4%. The company also reported operating income of $16.91     <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> billion and net income of $12.45 billion.                                                            <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                              <span style=\"font-weight: bold\">Conclusion</span>                                              <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span>                                                                                                      <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> NVIDIA Corporation remains a key player in the technology sector, with a strong presence in graphics <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> processing units, artificial intelligence, and data center networking solutions. The company's       <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> financial performance continues to be robust, driven by its diverse business segments and strategic  <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> investments. The recent stock split and increased dividend are expected to enhance shareholder value <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">│</span>          <span style=\"color: #000080; text-decoration-color: #000080\">│</span> and attract new investors. As the company continues                                                  <span style=\"color: #000080; text-decoration-color: #000080\">│</span>\n<span style=\"color: #000080; text-decoration-color: #000080\">╰──────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n</pre>\n",
         "text/plain": "\u001b[34m╭──────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────╮\u001b[0m\n\u001b[34m│\u001b[0m\u001b[1m \u001b[0m\u001b[1mMessage \u001b[0m\u001b[1m \u001b[0m\u001b[34m│\u001b[0m\u001b[1m \u001b[0m\u001b[1mWhat is the price of Nvidia stock? write a report about Nvidia in detail                            \u001b[0m\u001b[1m \u001b[0m\u001b[34m│\u001b[0m\n\u001b[34m├──────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────┤\u001b[0m\n\u001b[34m│\u001b[0m Response \u001b[34m│\u001b[0m \u001b[1mNVIDIA Corporation (NVDA) Stock Price and Overview\u001b[0m                                                   \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m (6.9s)   \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                             \u001b[1mStock Price\u001b[0m                                              \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m As of the current market, the stock price of NVIDIA Corporation (NVDA) is $124.30, with a trading    \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m volume of 261,458,283 shares. This represents a positive change of 0.62% compared to the previous    \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m day's close.                                                                                         \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                           \u001b[1mCompany Overview\u001b[0m                                           \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m NVIDIA Corporation is a leading visual computing company based in Santa Clara, California. Founded   \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m in 1993, the company operates globally, with significant presence in the United States, Taiwan,      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m China, and Hong Kong. NVIDIA's primary business segments include Graphics, Compute & Networking, and \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m Automotive.                                                                                          \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                          \u001b[1mBusiness Segments\u001b[0m                                           \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mGraphics\u001b[0m: NVIDIA's Graphics division delivers GeForce GPUs for gaming and personal computers,     \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0mGeForce NOW for game streaming, and solutions for gaming platforms. It also offers Quadro/NVIDIA  \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0mGPUs for workstation graphics, GPU software for cloud-based visual computing, and automotive      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0mplatforms for infotainment systems.                                                               \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mCompute & Networking\u001b[0m: This sector includes Data Center computing platforms, end-to-end networking \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0mplatforms, the NVIDIA DRIVE automated-driving platform, Jetson robotics, and NVIDIA AI Enterprise \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0msoftware.                                                                                         \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mAutomotive\u001b[0m: NVIDIA provides solutions for automotive industries, including infotainment systems   \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0mand autonomous driving platforms.                                                                 \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                          \u001b[1mFinancial Insights\u001b[0m                                          \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mMarket Capitalization\u001b[0m: NVIDIA's market capitalization stands at $3.195 trillion.                  \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mProfitability Metrics\u001b[0m:                                                                            \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mProfit Margin\u001b[0m: 53.40%.                                                                         \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mReturn on Assets (ROA)\u001b[0m: 49.10%.                                                                \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0m\u001b[1;33m • \u001b[0m\u001b[1mReturn on Equity (ROE)\u001b[0m: 115.66%.                                                               \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mRevenue\u001b[0m: The company generated $79.77 billion in the trailing twelve months.                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mCash and Cash Equivalents\u001b[0m: Total cash stands at $31.44 billion, with levered free cash flow of    \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0m$29.02 billion.                                                                                   \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                         \u001b[1mRecent Market Trends\u001b[0m                                         \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m The second quarter of 2024 witnessed a positive trend in the equity market, with the S&P 500 showing \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m a 4% increase and a year-to-date gain of nearly 15%. Growth sectors, particularly Information        \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m Technology and Communication Services, led the market during this period. However, sectors like      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m Estate, Materials Industrials Financial, and faced challenges. Looking ahead, the focus remains on   \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m Tech and Communications groups, with a question mark on whether small-caps will accelerate their     \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m growth. Amidst declining interest rates, growth stocks are expected to drive the market, while       \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m investors eyeing value are advised to consider dividends with yields in the 3-4% range.              \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                            \u001b[1mRecent Events\u001b[0m                                             \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1m10-for-1 Stock Split\u001b[0m: NVIDIA announced a ten-for-one forward stock split to make stock ownership  \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0mmore accessible to employees and investors. The split will be effective on June 10, 2024, and     \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0mtrading will commence on a split-adjusted basis.                                                  \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mIncreased Cash Dividend\u001b[0m: The company increased its quarterly cash dividend by 150% from $0.04 per \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0mshare to $0.10 per share of common stock. The increased dividend is equivalent to $0.01 per share \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0mon a post-split basis and will be paid on June 28, 2024, to all shareholders of record on June    \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m \u001b[1;33m   \u001b[0m11, 2024.                                                                                         \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                          \u001b[1mFinancial Results\u001b[0m                                           \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m NVIDIA announced its financial results for the first quarter of fiscal 2025, reporting revenue of    \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m $26.04 billion and a gross margin of 78.4%. The company also reported operating income of $16.91     \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m billion and net income of $12.45 billion.                                                            \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                              \u001b[1mConclusion\u001b[0m                                              \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m                                                                                                      \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m NVIDIA Corporation remains a key player in the technology sector, with a strong presence in graphics \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m processing units, artificial intelligence, and data center networking solutions. The company's       \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m financial performance continues to be robust, driven by its diverse business segments and strategic  \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m investments. The recent stock split and increased dividend are expected to enhance shareholder value \u001b[34m│\u001b[0m\n\u001b[34m│\u001b[0m          \u001b[34m│\u001b[0m and attract new investors. As the company continues                                                  \u001b[34m│\u001b[0m\n\u001b[34m╰──────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
        },
        "metadata": {},
        "output_type": "display_data"
       }
      ]
     }
    },
    "69a9dfbdaa454445b3a75ba27905f5b7": {
     "model_module": "@jupyter-widgets/base",
     "model_module_version": "1.2.0",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
